package model

import "github.com/gogf/gf/v2/util/gmeta"

type EquipmentIdRes struct {
	Id string `json:"id"  dc:"设备id"    v:"required#设备id必填"`
}

//EquipmentInfoRes 设备的详情
type EquipmentInfoRes struct {
	SiteId    string `json:"siteId"     dc:"站点id"  v:"required#站点id必填"`
	EqCode    string `json:"eqCode"  dc:"设备号(可新增/无法编辑)" v:"required|max-length:50#设备号必填|设备号不超过50字"`
	EqName    string `json:"eqName"  dc:"设备名称" v:"required|max-length:20#设备名称必填|设备名称不超过20字"`
	BillingId string `json:"billingId" dc:"计费Id" v:"required#设备计费类型必填"`
	EqPorts   int    `json:"eqPorts"  dc:"设备的端口数量(可新增/无法编辑)" v:"in:10,20|integer#设备端口数量只能按枚举填写|设备数量必须是一个整数"`
	EqRemark  string `json:"eqRemark"   dc:"站点备注"  v:"max-length:50#设备备注不超过140字"`
}

type SearchEquipmentListRes struct {
	SiteId string `json:"siteId"     dc:"站点id"  v:"required#站点id必填"`
	EqCode string `json:"eqCode"  dc:"设备号" v:"max-length:50#设备号不超过50字"`
	EqName string `json:"eqName"  dc:"设备名称" v:"max-length:50#设备名称不超过50字"`
	*Paging
}

type EquipmentIdAndInfoRes struct {
	EquipmentIdRes
	EquipmentInfoRes
	CreatedAt string `json:"createdAt" dc:"创建时间" `
}

type EquipmentListPageRes struct {
	List []*EquipmentDbInfoPortRes `json:"list"  dc:"设备列表"`
	PutPage
}

type EquipmentDbInfoPortRes struct {
	gmeta.Meta `orm:"table:lot_equipment"`
	*EquipmentInfoRes
	*EquipmentDetailReq
	Id            string                    `json:"id"  dc:"设备id"    v:"required#设备id必填"`
	CreatedAt     string                    `json:"createdAt" dc:"创建时间" `
	PortList      []*EquipmentPortDbInfoRes `json:"portList" dc:"端口列表" orm:"with:eq_id=id"`
	BillingScheme *BillingDbInfoRes         `json:"billingScheme" dc:"收费方案" orm:"with:id=billing_id"`
}

// EquipmentDbInfoRes 通过该设备的端口查询的参数
type EquipmentDbInfoRes struct {
	gmeta.Meta `orm:"table:lot_equipment"`
	EquipmentIdRes
	EquipmentInfoRes
}

// EquipmentDbInfoAndSiteRes 通过设备id 获取设备详情 端口列表 和 站点详情
type EquipmentDbInfoAndSiteRes struct {
	gmeta.Meta `orm:"table:lot_equipment"`
	EquipmentInfoRes
	EquipmentDetailReq
	Id            string                    `json:"id"  dc:"设备id"`
	PortList      []*EquipmentPortDbInfoRes `json:"portList" dc:"端口列表" orm:"with:eq_id=id"`
	SiteInfo      *SiteDbOderEquipmentRes   `json:"siteInfo" dc:"站点信息" orm:"with:id=site_id"`
	BillingScheme *BillingDbInfoRes         `json:"billingScheme" dc:"收费方案" orm:"with:id=billing_id"`
}

// EquipmentDetailReq 这些数据是硬件数据 需要通过mqtt查询
type EquipmentDetailReq struct {
	EqMode                       string `json:"eqMode" dc:"工作模式"`
	EqTotalPower                 int    `json:"eqTotalPower"  dc:"总功率/w"`
	EqQuickChargingMax           int    `json:"eqQuickChargingMax"  dc:"快充端口上限/w"`
	EqQuickChargingMin           int    `json:"eqQuickChargingMin" dc:"快充端口下限/w"`
	EqSlowChargingMin            int    `json:"eqSlowChargingMin" dc:"慢冲端口下限/w"`
	EqSlowChargingMax            int    `json:"eqSlowChargingMax"  dc:"慢冲端口上限/w"`
	EqLowTemperature             int    `json:"eqLowTemperature" dc:"最低温度/℃"`
	EqHighTemperature            int    `json:"eqHighTemperature" dc:"最高温度/℃"`
	EqTemperature                int    `json:"eqTemperature" dc:"当前温度/℃" `
	EqPower                      int    `json:"eqPower"   dc:"当前总功率/w"`
	EqGprs                       string `json:"eqGprs"  dc:"当前信号 1~30 范围值 15算正常"`
	EqAbnormalTime               int    `json:"eqAbnormalTime"  dc:"充点异常时间"`
	EqHeartbeatTime              int    `json:"eqHeartbeatTime"   dc:"设备的心跳时间"`
	EqWarningTemperature         int    `json:"eqWarningTemperature" dc:"警告温度/℃"`
	EqVersion                    string `json:"eqVersion" dc:"设备的软件版本"`
	EqImei                       string `json:"eqImei"  dc:"设备硬件的唯一标识符"`
	EqHistoricalTotalElectricity int    `json:"eqHistoricalTotalElectricity" dc:"历史总电量"`
}

type StartEquipmentReq struct {
	*EquipmentIdRes
	PortCode     int   `json:"portCode"  dc:"设备的端口号" v:"required|min:1|integer#端口号必填|端口号不能小于1|端口号必须是一个整数"`
	Time         int64 `json:"time" dc:"充电的时长/分钟" v:"required|integer|max:65535#端口号必填|充电的时长必须是一个整数|最大值不超过65535分钟"`
	ChargingMode int   `json:"chargingMode" dc:"充电方式 1 扫码充电 2 刷卡充电" v:"required|in:1,2#充电方式必填|1扫码充电、2刷卡充电"`
}

type StopEquipmentReq struct {
	*EquipmentIdRes
	PortCode  int    `json:"portCode"  dc:"设备的端口号" v:"required|min:1|integer#端口号必填|端口号不能小于1|端口号必须是一个整数"`
	EndReason string `json:"end_reason"  dc:"结束原因 01 充满自停  02 功率过低 03 功率过高 04.零功率（未插充电器充电或保 险丝断）05. 充电器被拔出（功率正常时突然为 0W 判被拔出）" v:"required#结束原因必填"`
}

type StopEquipmentRes struct {
	Id        string `json:"id"  dc:"设备id"    v:"required#设备id必填"`
	PortCode  int    `json:"portCode"  dc:"设备的端口号" v:"required|min:1|integer#端口号必填|端口号不能小于1|端口号必须是一个整数"`
	EndReason string `json:"end_reason"  dc:"结束原因 01 充满自停  02 功率过低 03 功率过高 04.零功率（未插充电器充电或保 险丝断）05. 充电器被拔出（功率正常时突然为 0W 判被拔出）" v:"required#结束原因必填"`
}

// StartEquipmentRes 启动设备返回的参数
type StartEquipmentRes struct {
	OrderId string `json:"orderId"  dc:"订单id"`
	EqCode  string `json:"eqCode"  dc:"设备号" `
}
